

using System;
using System.Collections.Generic;
using System.Text;
using EntityLayer;
using System.Data;
using DataAccessLayer;
using InfraStructureLayer;

namespace DataLayer
{
	public class datLinks
	{
		public datLinks()
		{
		}
		
		#region  Code Factory Generated Methods
		public void DeleteLinksByLinkId(entLinks parEntLinks, DbConnector parDbConnector)
		{
			DbParamCollection insDbParamCollection = new DbParamCollection();
			insDbParamCollection.Add("@pLinkId",parEntLinks.LinkId);
			parDbConnector.ExecuteNonQuery("DeleteLinksByLinkId",insDbParamCollection);
		}
		public void InsertLinks(entLinks parEntLinks, DbConnector parDbConnector)
		{
			DbParamCollection insDbParamCollection = new DbParamCollection();
			insDbParamCollection.Add("@pLinkAddress",parEntLinks.LinkAddress);
			insDbParamCollection.AddOutput("@pLinkId",DbType.Int32);
			parDbConnector.ExecuteNonQuery("InsertLinks",insDbParamCollection);
			parEntLinks.LinkId = Convert.ToInt32(insDbParamCollection.GetOutPutParameter().Value);
		}
		public void UpdateLinksByLinkId(entLinks parEntLinks, DbConnector parDbConnector)
		{
			DbParamCollection insDbParamCollection = new DbParamCollection();
			insDbParamCollection.Add("@pLinkId",parEntLinks.LinkId);
			
			insDbParamCollection.Add("@pLinkAddress",parEntLinks.LinkAddress);
			parDbConnector.ExecuteNonQuery("UpdateLinksByLinkId",insDbParamCollection);
		}
		public DataTable SelectLinks(DbConnector parDbConnector)
		{
			
			return parDbConnector.ExecuteDataTable("SelectLinks",null);
		}
		public void SelectLinksByLinkId(entLinks parEntLinks, DbConnector parDbConnector)
		{
			DbParamCollection insDbParamCollection = new DbParamCollection();
			insDbParamCollection.Add("@pLinkId",parEntLinks.LinkId);
			DataTable insDataTable = new DataTable();
			insDataTable = parDbConnector.ExecuteDataTable("SelectLinksByLinkId",insDbParamCollection);
			if (insDataTable.Rows.Count>0)
			{
				if (insDataTable.Rows[0]["LinkId"]!=DBNull.Value)
				{
					parEntLinks.LinkId = Convert.ToInt32(insDataTable.Rows[0]["LinkId"]);
				}
				if (insDataTable.Rows[0]["LinkAddress"]!=DBNull.Value)
				{
					parEntLinks.LinkAddress = insDataTable.Rows[0]["LinkAddress"].ToString();
				}
			}
		}
		
		#endregion

        public DataTable SelectLinksRandom(DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pLanguageId", CurrentContext.LanguageId);
            return parDbConnector.ExecuteDataTable("SelectLinksRandom", insDbParamCollection);
        }
        public DataTable SelectLinksByLanguageId(DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pLanguageId", CurrentContext.LanguageId);
            return parDbConnector.ExecuteDataTable("SelectLinksByLanguageId", insDbParamCollection);
        }

	}
}